//
//  ServiceConfigProtocol.h
//  ShopInMall_OC
//
//  Created by Sailer Guo on 2019/10/11.
//  Copyright © 2019 Sailer Guo. All rights reserved.
//

#ifndef ServiceConfigProtocol_h
#define ServiceConfigProtocol_h

#import "EnvironmentConstants.h"
#import <AFNetworking/AFNetworking.h>
NS_ASSUME_NONNULL_BEGIN



typedef NSUInteger NSErrorCode;

// 请求上品的服务，服务端已经处理了结果也返回了，但没有返回正确的数据
FOUNDATION_EXPORT NSErrorDomain const NSErrorDomainNoAdaptiveData;
FOUNDATION_EXPORT NSErrorCode const NSSPErrorCode;

NS_PROTOCOL_REQUIRES_EXPLICIT_IMPLEMENTATION

@protocol ServiceConfig <NSObject>

#pragma mark - 处理请求数据
@property (nonnull,nonatomic,copy) NSString *baseUrl;
@property (nonatomic,assign) EnvironmentType env;

@optional

@property (nonatomic,assign,class) NSTimeInterval networkTimeout;
@property (nonatomic,strong) AFHTTPSessionManager * _Nullable session;
@property (nonatomic,copy) NSString *baseImageUrl;

+ (id<ServiceConfig>)serviceConfigWith:(EnvironmentType)env;

+ (void)switchEenvironment:(EnvironmentType)env;

#pragma mark - 处理返回数据

- (BOOL)successWitResponseObject:(id _Nonnull )responseObject;
- (id _Nonnull )responseData:(id _Nonnull )responseObject withUrl:(NSString *)url isList:(BOOL)isList ;
- (NSError *_Nonnull)errorMessage:(id _Nullable )responseObject withUrl:(NSString *)url;


@end


#endif /* ServiceConfigProtocol_h */

NS_ASSUME_NONNULL_END

